package org.xc.studentssystem.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.xc.studentssystem.mapper.SignUpMapper;
import org.xc.studentssystem.pojo.User;

@Slf4j
@RestController
public class SignUpController {

    @Autowired
    private SignUpMapper signUpMapper;
    @Autowired
    private PasswordEncoder passwordEncoder;

    @RequestMapping("/signup")
    public String signUp(@RequestBody User user){

        //密码加密
        user.setPassword(passwordEncoder.encode(user.getPassword()));

        signUpMapper.insert(user);
        return "success";
    }

}
